package test;

import java.io.File;
import java.net.MalformedURLException;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

public class xpath {
	public static void main(String[] args) throws DocumentException, MalformedURLException {
		// SAXReader saxReader;
		// Document doc;
		// saxReader = new SAXReader();
		// try {
		// doc = (Document) saxReader.read(new File(""));
		// } catch (DocumentException ex) {
		// throw new RuntimeException(ex);
		// }
		SAXReader saxReader = new SAXReader();
		Document doc = saxReader.read(new File("src/student.xml"));
		String xPathExpress = "//Item[Key='name']//Value";// name为你需要的获取值，value为indexNum的值
		System.out.println(doc.selectSingleNode(xPathExpress).getText());
	}
}
